import dayjs from "dayjs"
export default function (app) {
  app.directive("format-time",{
    mounted (el,bindings) {
      const textContent = el.textContent
      const formatString = bindings.value || "YYYY-MM-DD HH:mm:ss"
      console.log(formatString,textContent);
      let timestamp = parseInt(textContent)
      if (textContent.length === 10){
        timestamp = timestamp * 1000
      }
      el.textContent = dayjs(timestamp).format(formatString)
    }
  })
}